package ZorkObjects;

import java.util.HashMap;
import java.util.ArrayList;

public class Trigger
{
    private Condition condition;
    private String command;
    private String type;
    private String print;
    private ArrayList<String> actions;
	private boolean haveTriggered = false;

    public Trigger(HashMap configMap)
    {
        condition = new Condition((HashMap)configMap.get("condition"));
        command = (String)configMap.remove("command");
        type = (String)configMap.remove("type");
        print = (String)configMap.remove("print");
        actions = new ArrayList<String>();

        Object actionObject = configMap.remove("action");
        if(actionObject instanceof String) {
            actions.add((String)actionObject);
        }
        else if(actionObject instanceof ArrayList) {
            actions = (ArrayList<String>)actionObject;
        }
    }

	public ArrayList<String> getActions() {
		return actions;
	}

	public String getCommand() {
		return command;
	}

	public Condition getCondition() {
		return condition;
	}

	public String getPrint() {
		return print;
	}

    public String toString() {
        return String.format("condition=[%s]\ncommand=%s\ntype=%s\nprint=%s\naction=%s\n", 
            condition, command, type, print, actions);
    }
}
